package com.gufe.mapper.user.excellentperson;

import com.gufe.entity.excellentperson.ExcellentPersonnel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExcellentPersonnelMapper {
    @Insert("INSERT INTO excellent_personnel (name, achievement, description, avatar, tags, moreInfo) " +
            "VALUES (#{name}, #{achievement}, #{description}, #{avatar}, #{tags}, #{moreInfo})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(ExcellentPersonnel personnel);

    @Select("SELECT id, name, achievement, description, avatar, tags, moreInfo FROM excellent_personnel WHERE id = #{id}")
    ExcellentPersonnel selectById(Integer id);

    @Update("UPDATE excellent_personnel SET name = #{name}, achievement = #{achievement}, " +
            "description = #{description}, avatar = #{avatar}, tags = #{tags}, moreInfo = #{moreInfo} " +
            "WHERE id = #{id}")
    int updateById(ExcellentPersonnel personnel);

    @Delete("DELETE FROM excellent_personnel WHERE id = #{id}")
    int deleteById(Integer id);

    @Select("SELECT id, name, achievement, description, avatar, tags, moreInfo FROM excellent_personnel")
    List<ExcellentPersonnel> selectAll();
}